#include <cstdio>
#include <vector>
using namespace std;
int N, M, S, D;
const int MAXN = 501;
const int INF = 1000000000;
int G[MAXN][MAXN], cost[MAXN][MAXN];
int dis[MAXN];
bool visit[MAXN] = {false};
vector<int> pre[MAXN];
vector<int> tmpath, path;
vector<int> tmcost;
int mincost = INF, tmp;
void Dijkstra(int s)
{
    fill(dis, dis + MAXN, INF);
    dis[s] = 0;
    int min, m;
    for (int i = 0; i < N; ++i)
    {
        min = INF;
        m = -1;
        for (int j = 0; j < N; ++j)
        {
            if (false == visit[j] && dis[j] < min)
            {
                m = j;
                min = dis[j];
            }
        }
        if (-1 == m)
            return;
        visit[m] = true;
        for (int j = 0; j < N; ++j)
        {
            if (false == visit[j] && G[m][j] != INF)
            {
                if (dis[m] + G[m][j] < dis[j])
                {
                    dis[j] = dis[m] + G[m][j];
                    pre[j].clear();
                    pre[j].push_back(m);
                }
                else if (dis[m] + G[m][j] == dis[j])
                {
                    pre[j].push_back(m);
                }
            }
        }
    }
}
void DFS(int d)
{
    if (pre[d].empty())
    {//递归边界
        tmpath.push_back(d);
        tmp = 0;
        for (int i = 0; i < N; ++i)
        {
            tmp += tmcost[i];
        }
        if (tmp < mincost)
        {
            path = tmpath; //可以直接赋值吗？
            mincost = tmp;
        }
        tmpath.pop_back();
        return;
    }
    else
    {
        tmpath.push_back(d);
        for (int i = 0; i < pre[d].size(); ++i)
        {//此处分解成size个子问题
            tmcost.push_back(cost[d][pre[d][i]]);
            DFS(pre[d][i]);
            tmcost.pop_back();
        }
        tmpath.pop_back();
    }
}
int main()
{
    fill(G[0], G[0] + MAXN * MAXN, INF);
    fill(cost[0], cost[0] + MAXN * MAXN, INF);
    scanf("%d%d%d%d", &N, &M, &S, &D);
    for (int i = 0; i < M; ++i)
    {
        int u, v;
        scanf("%d%d", &u, &v);
        scanf("%d%d", &G[u][v], &cost[u][v]);
        G[v][u] = G[u][v];
        cost[v][u] = cost[u][v];
    }
    Dijkstra(S);
    DFS(D);
    for (int i = path.size() - 1; i >= 0; --i)
    {
        printf("%d ", path[i]);
    }
    printf("%d %d\n", dis[D], mincost);
}